package com.itheima.behavior.controller;

import com.heima.model.common.dtos.*;
import com.itheima.behavior.server.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "用户行为api",tags = "用户行为api")
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;
    @Autowired
    private ApReadBehaviorService apReadBehaviorService;
    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehaviorService;
    @Autowired
    private ApCollectionBehaviorService apCollectionBehaviorService;
    @Autowired
    private ApArticleBehaviorService apArticleBehaviorService;
    @ApiOperation("用户点赞api")
    @PostMapping("/likes_behavior")
    ResponseResult likeBehavior(@RequestBody @Validated LikesBehaviorDTO dto){
         return apLikesBehaviorService.like(dto);

    }
    @ApiOperation("用户阅读api")
    @PostMapping("/read_behavior")
    ResponseResult readBehavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }
    @ApiOperation("用户不喜欢api")
    @PostMapping("/un_likes_behavior")
    ResponseResult unLikeBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }
    @ApiOperation("用户收藏api")
    @PostMapping("/collection_behavior/")
    ResponseResult collectionBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }
    @ApiOperation("用户收藏api")
    @PostMapping("/article/load_article_behavior")
    ResponseResult loadArticle(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }

}
